# -*- coding: utf-8 -*-
"""
comments
"""
import json
import math


def main():
    IN_FILE = "tmp.csv"
    OUT_FILE = "tmp.json"

    result = []
    max_value = 0.0
    with open(IN_FILE, "r") as fd:
        for line in fd:
            name, value = line.strip().split(",")
            # value = value.strip().replace(",", "")
            if value == "-":
                value = 0
            else:
                value = int(value)

            max_value = max(max_value, math.sqrt(value))
            result.append({
                "name": name,
                "value": value,
                # "pv": value,
            })

    # for each_obj in result:
        # each_obj["value"] = math.sqrt(each_obj["value"]) / max_value

    with open(OUT_FILE, "w")as fd:
        json.dump(result, fd, indent=2, ensure_ascii=False, encoding="utf-8")


if __name__ == '__main__':
    main()
    print("done")
